<div class="container-fluid">

	<!-- affichage des messages Flash-->
	<div class="row-fluid">
		<div class="span12">
			<?php echo $this->Session_gpp->flash(); ?>
	 	</div>
	</div>

	<!-- Chemin fil conducteur -->
  	<div class="row-fluid">
		<div class="span12">
			<ul class="breadcrumb">
		      	<?php 
					echo '<li>'.$this->Html->link('Applications',array('controller'=>'applications','action'=>'index')).'</span>/</span></li>';
				?>
				<?php 
					echo '<li class="active">'.$this->Html->link(h($application['Application']['name']),array('controller'=>'applications','action'=>'View',$application['Application']['id']))."</li>";
				?>
			</ul>
		</div>
	</div>

	<!-- entete des onglets -->
  	<div class="row-fluid">
		<div class="span12">
			<ul id="tab" class="nav nav-tabs">
			  <li><a href="#Application" data-toggle="tab">Application</a></li>
			  <li class="active"><a href="#Versions" data-toggle="tab">Versions</a></li>
			  <li><a href="#Fonctions" data-toggle="tab">Fonctions</a></li>
			</ul>
	 	</div>
	</div>

	<!-- detail des onglets -->
	<div id="myTabContent" class="tab-content">
		<!-- Onglet Application -->
	  	<div class="tab-pane fade in" id="Application">
	  		<div class="navbar"/>
				<div class="navbar-inner_gpp">
					<div class="container-fluid">
						<div class="nav-collapse">
							<div class="row-fluid">
								<div class="span2">
									<a href="../edit/<?php echo $application['Application']['id'];?>" class="btn btn-info btn-small" >
										<i class="icon-pencil icon-white"></i><?php echo __(' Application')?>
									</a>
								</div>
								<div class="span2">
									<p>
										<?php echo $this->Moninput->deleteInverse(
													__('Delete Application'),
													$application['Application']['id'], 
													'Applications',
													__('Are you sure you want to delete # '.$application['Application']['id'].'?')
												); ?>
									</p>
								</div>
								<div class="span2">	
									<a href="#?w=500" onclick="TesterConnexion()" class="btn btn-inverse btn-small"><i class="icon-signal icon-white"></i><?php echo __(' Tester la connexion')?></a>
						  		</div>
								<div class="span6">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row-fluid">
				<div class="span4">
					<div class="hero-unit">
						<dl>
							<h1><?php echo h($application['Application']['name']); ?></h1>
								&nbsp;
							<h2><?php echo h($application['Application']['description']); ?></h2>
						</dl>
					</div>
				</div>
				<div class="span4">
					<fieldset>
						<div class="input text">
							<label for="name">Name</label>
							<input name="data[Application][name]" readonly="readonly" type="text" id="ApplicationName" value="<?php echo h($application['Application']['name']); ?>"/>
						</div>
						<div class="input text">
							<label for="name">Description</label>
							<textarea name="data[Application][description]" cols="30" rows="6" id="ApplicationDescription" readonly="readonly" ><?php echo h($application['Application']['description']); ?></textarea>
						</div>
						<div class="input text">
							<label for="ApplicationHebergement">Hebergement</label>
							<select name="data[Application][hebergement]" id="ApplicationHebergement" disabled>
								<option value="0" <?php if (h($application['Application']['hebergement'])==0) echo 'selected'; ?> >
									<?php echo __('Bdd local')?>
								</option>';
								<option value="1" <?php if (h($application['Application']['hebergement'])==1) echo 'selected'; ?>>
									<?php echo __('Bdd distante')?>
								</option>';
							</select>
						</div>
					</fieldset>
				</div>
				<div class="span4">
					<fieldset>
						<h4> Info Connexion Bdd Distante</h4>
						<div class="input text">
							<label for="ApplicationPgdatabase_id">Database</label>
							<select name="data[Application][pgdatabase_id]" id="ApplicationPgdatabase_id" disabled>
								<?php foreach ($pgdatabases as $key => $value) {?>
									<option value="<?php echo $key;?>" <?php if($key==h($application['Application']['pgdatabase_id'])) echo 'selected';?> >
										<?php echo $value;?> 
									</option>;
								<?php }?>
							</select>
						</div>
						<div class="input text">
							<label for="name">Host</label>
							<input name="data[Application][host]" readonly="readonly" type="text" id="ApplicationHost" value="<?php echo h($application['Application']['host']); ?>"/>
						</div>
						<div class="input text">
							<label for="name">Port</label>
							<input name="data[Application][port]" readonly="readonly" type="text" id="ApplicationPort" value="<?php echo h($application['Application']['port']); ?>"/>
						</div>
						<div class="input text">
							<label for="name">Sid</label>
							<input name="data[Application][sid]" readonly="readonly" type="text" id="ApplicationSid" value="<?php echo h($application['Application']['sid']); ?>"/>
						</div>
						<div class="input text">
							<label for="name">Login</label>
							<input name="data[Application][login]" readonly="readonly" type="text" id="ApplicationLogin" value="<?php echo h($application['Application']['login']); ?>"/>
						</div>
						<div class="input text">
							<label for="name">Mdp</label>
							<input name="data[Application][mdp]" readonly="readonly" type="text" id="ApplicationMdp" value="<?php echo h($application['Application']['mdp']); ?>"/>
						</div>
					</fieldset>
				</div>
			</div>
	  	</div>

		<!-- Onglet Versions -->
		<div class="tab-pane active" id="Versions">
	  		<div class="navbar"/>
				<div class="navbar-inner_gpp">
					<div class="container-fluid">
						<div class="nav-collapse">
							<div class="row-fluid">
								<div class="span2">
									<a href="../../versions/add/<?php echo $application['Application']['id'];?>" class="btn btn-primary btn-small" >
										<i class="icon-plus-sign icon-white"></i><?php echo __(' Version')?>
									</a>
								</div>
								<div class="span10">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
	
			<div class="page-header">
				<?php if (!empty($application['Version'])):?>
					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
								<th width="1px"><?php echo __('Id'); ?></th>
								<th><?php echo __('Name'); ?></th>
								<th><?php echo __('Description'); ?></th>
								<th align="center" width="1px"/>
							</tr>
						</thead>
						<tbody>	
							<?php
							$i = 0;
							foreach ($application['Version'] as $version): ?>
								<tr>
									<td align="left"><?php echo $version['id'];?></td>
									<td align="left"><?php echo $this->Html->link(h($version['name']),array('controller'=>'versions','action'=>'view',$version['id'])); ?>&nbsp;
									</td>
									<td align="left"><?php echo h($version['description']);?></td>
									<td class="center">
										<p>
											<?php echo $this->Moninput->delete(
														__('Delete'),
														$version['id'], 
														'Versions',
														__('Are you sure you want to delete # '.$version['id'].'?')
													); ?>
										</p>
									</td>
								</tr>
							<?php endforeach; ?>
						</tbody>
					</table>
				<?php endif; ?>
			</div>
		</div>

		<!-- Onglet Fonctions -->
		<div class="tab-pane" id="Fonctions">
	  		<div class="navbar"/>
				<div class="navbar-inner_gpp">
					<div class="container-fluid">
						<div class="nav-collapse">
							<div class="row-fluid">
								<div class="span2">
									<a href="../../fonctions/add/<?php echo $application['Application']['id'];?>" class="btn btn-primary btn-small" >
										<i class="icon-plus-sign icon-white"></i><?php echo __(' Fonction')?>
									</a>
								</div>
								<div class="span10">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="page-header">
				<?php if (!empty($application['Fonction'])):?>
					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example2">
						<thead>
							<tr>
								<th width="1px"><?php echo __('Id'); ?></th>
								<th><?php echo __('Name'); ?></th>
								<th><?php echo __('Description'); ?></th>
								<th align="center" width="1px"/>
							</tr>
						</thead>
						<tbody>	
							<?php
							$i = 0;
							foreach ($application['Fonction'] as $fonction): ?>
								<tr>
									<td><?php echo $fonction['id'];?></td>
									<td align="left"><?php echo $this->Html->link(h($fonction['name']),array('controller'=>'fonctions','action'=>'view',$fonction['id'])); ?>&nbsp;
									</td>
									<td><?php echo h($fonction['description']);?></td>
									<td class="center">
										<p>
											<?php echo $this->Moninput->delete(
														__('Delete'),
														$fonction['id'], 
														'Fonctions',
														__('Are you sure you want to delete # '.$fonction['id'].'?')
													); ?>
										</p>
									</td>
								</tr>
							<?php endforeach; ?>
						</tbody>	
					</table>

					<script type="text/javascript" charset="utf-8">
						$(document).ready(function() {
							$('#example2').dataTable( {
								"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
								"sPaginationType": "bootstrap",
								"oLanguage": {
									"sLengthMenu": "_MENU_ records per page"
								}
							} );
						} );
					</script>
				<?php endif; ?>

			</div>
		</div>
	</div>
 
	<!-- Chargement des onglets-->
	<script type="text/javascript" charset="utf-8">
	  $(function () {
	    $('.tabs a:last').tab('show')
	  })
	</script>

</div>


<!-- Chargement des onglets-->
<script type="text/javascript" charset="utf-8">
  $(function () {
    $('.tabs a:last').tab('show')
  })
</script>

<!-- Ajax de Test des infos de connexion-->
<script type="text/javascript">
	
	function TesterConnexion (){
		var ApplicationPgdatabase=document.getElementById('ApplicationPgdatabase_id').value;
		var ApplicationHost=document.getElementById('ApplicationHost').value;
		var ApplicationPort=document.getElementById('ApplicationPort').value;
		var ApplicationSid=document.getElementById('ApplicationSid').value;
		var ApplicationLogin=document.getElementById('ApplicationLogin').value;
		var ApplicationMdp=document.getElementById('ApplicationMdp').value;

		var urlTester="../TesterConnexion_ajax/"+ApplicationPgdatabase+"/"+ApplicationHost+"/"+ApplicationPort+"/"+ApplicationSid+"/"+ApplicationLogin+"/"+ApplicationMdp;

		//alert(urlTester);

		$.ajax({
		  	type: "GET",
		  	url: urlTester,
		   	error:function(msg){
		     	alert( "Error !: " + msg );
		   	},
		   	success:function(data){
		   		alert(data);
			}
		});
	}
</script>






